home *** CD-ROM | disk | FTP | other *** search
- Path: gryphon.phoenix.net!usenet
- From: brucew@phoenix.net (Bruce Wedding)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with arrays
- Date: Wed, 31 Jan 1996 07:13:27 GMT
- Organization: BranPaul Systems
- Message-ID: <4en2ig$6af@gryphon.phoenix.net>
- References: <4ejtia$6id@sifon.cc.mcgill.ca>
- NNTP-Posting-Host: dial73.phoenix.net
- X-Newsreader: Moe's Newsreader
-
-
- >typedef struct nodebox NODEBOX, *TRIE
- >
- >struct nodebox{
- >{ int letters[100];
- > TRIE subtree[100];
- >};
- > But here's the problem: before inserting any letter in the trie, I expect the
- >elements in the array letters to be all zeros( '\0' ) like in a normal empty
- >array. But instead, the elements of this arrays are weird numbers like
- >25678. It bothers me since I assume that they are '\0' in my insert function.
-
- C does not explicitly initialize arrays unless they are defined
- global. You will have to zero out the array. You can use a loop
- or the memset function. I think the loop is a little safer,
- though maybe not as fast.
-
- NODEBOX test;
- int i = 0;
-
- for (; i < sizeof(test.letters)/sizeof(test.letters[0]); i++)
- test.letters[i] = 0;
-
-
- Bruce D. Wedding Have Compiler, Will Travel!
- Perspicacious Programming Performed Promptly
- Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
-